package com.example.mqdemo.subscribe;

import jakarta.annotation.Resource;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.stereotype.Component;

/*
 *@description: 发布/订阅模式消息发布者
 *@author: hisen
 *@Time: 2023/11/22  17:16
 */
@Component("subscribeProducer")
public class SubscribeProducer {
    @Resource
    AmqpTemplate amqpTemplate;

    public void sendMessage(String message) {
        for (int i = 1; i <= 5; i++) {
            amqpTemplate.convertAndSend("subscribeExchange", "", message + i);
        }
    }
}
